using System;
using System.Collections.Generic;
using System.Text;
using NDomain;

namespace NDomain.ExampleModels.BloggingSystem
{
    [Entity]
    [AggregateItem("Blog")]
    public class Article : Content
    {
        private long _id;

        public long Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private IList<Comment> _comments = new List<Comment>();

        public IList<Comment> Comments
        {
            get { return new List<Comment>(_comments).AsReadOnly(); }
        }

        public Comment AddComment(string text, string author)
        {
            Comment newComment = new Comment(text, author);
            _comments.Add(newComment);
            return newComment;
        }

        private string _title;

        public string Title
        {
            get { return _title; }
            set { _title = value; }
        }

        internal Article(string title, string text, string author) : base(text, author)
        {
            _title = title;
        }
    }
}
